package net.huashitong.ssydt.provider.pk.service;


import net.huashitong.ssydt.base.dao.LongMapper;
import net.huashitong.ssydt.base.service.AbstractLongService;
import net.huashitong.ssydt.pk.entity.SsPkYzddRank;
import net.huashitong.ssydt.pk.entity.vo.RankingInVO;
import net.huashitong.ssydt.provider.pk.mapper.SsPkYzddRankMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author <a href="mailto:yhy23456@163.com">huiyang.yu</a>
 * @since 2017.12.19
 */
@Service
@Transactional
public class SsPkYzddRankServiceImpl extends AbstractLongService<SsPkYzddRank> implements SsPkYzddRankService {

    private SsPkYzddRankMapper mapper;

    @Autowired
    public SsPkYzddRankServiceImpl(SsPkYzddRankMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    protected LongMapper<SsPkYzddRank> getLongMapper() {
        return this.mapper;
    }

    @Override
    public int deleteByMatchRecordId(Long matchRecordId) {
        return this.mapper.deleteByMatchRecordId(matchRecordId);
    }

    @Override
    public int batchInsert(List<SsPkYzddRank> ssPkYzddRanks) {
        if (ssPkYzddRanks.isEmpty()) {
            return 0;
        }
        return this.mapper.batchInsert(ssPkYzddRanks);
    }

    @Override
    public SsPkYzddRank getByMatchRecordIdWithUserId(Long matchRecordId, String userId) {
        SsPkYzddRank ssPkYzddRank = new SsPkYzddRank();
        ssPkYzddRank.setMatchRecordId(matchRecordId);
        ssPkYzddRank.setUserId(userId);
        return this.mapper.getByMatchRecordIdWithUserId(ssPkYzddRank);
    }

    @Override
    public List<SsPkYzddRank> query(RankingInVO rankingInVO) {
        return this.mapper.query(rankingInVO);
    }

    @Override
    public List<SsPkYzddRank> findTopTen(Long matchRecordId) {
        return this.mapper.findTopTen(matchRecordId);
    }
}
